Coding club 01/08/2019

Plotting neurons! In 3D!

In [1]:
import pymaid
pymaid.set_pbars(jupyter=False, leave=False)
pymaid.set_loggers('WARNING')
# Set catmaid login instance
rm = pymaid.CatmaidInstance('https://neuropil.janelia.org/tracing/fafb/v14',
                           'fly',
                           'superfly',
                           '5db25732b0560af54d41a67e49777e5233f1f229')

Tasks:

Plot all 20 neurons
Colour by a subset (excitatory vs inhibitory)
Plot Neuropil volumes alongside neurons
Using a single neuron: 
    Differently colour the pre and post synaptic sites
    Plot so the axons and dendrites are different colours
    Colour the neuron by strahler order
In [2]:
# Data
Ex = pymaid.get_neurons('annotation:Rclub_1807_Ex') 
In = pymaid.get_neurons('annotation:Rclub_1807_In')
Single = pymaid.get_neurons('1722886')
                                                             
In [3]:
# Plot all 20 neurons together
pymaid.plot3d([Ex,In],width = 1200)
In [4]:
# Colour neurons by type
In_colours = dict.fromkeys(In.skeleton_id, [1,0,1])
Ex_colours = dict.fromkeys(Ex.skeleton_id, [0,1,1])
colours_dict = {**In_colours,**Ex_colours}
pymaid.plot3d([Ex,In],width = 1200,color = colours_dict)
In [5]:
# Plot Neuropil volumes alongside neurons
AL = pymaid.get_volume('AL_R')
LH = pymaid.get_volume('LH_R')
pymaid.plot3d([In,Ex,AL,LH],width = 1200,color = colours_dict)
In [6]:
#    Using a single neuron: 
#        Differently colour the pre and post synaptic sites
pymaid.plot3d(Single,width = 1200,color = colours_dict,connectors = True)
In [7]:
#    Using a single neuron: 
#        Plot so the axons and dendrites are different colours
Single_dendrite = Single.prune_proximal_to('dendrite',inplace = False)
Single_axon = Single.prune_proximal_to('axon',inplace = False)

pymaid.plot3d([Single,Single_dendrite,Single_axon],color = [(1,0,1),(0,1,1),(1,1,0)])
In [8]:
#    Using a single neuron: 
#        Colour the neuron by strahler order
Single = pymaid.get_neurons('1722886')
pymaid.reroot_neuron(Single,'soma',inplace=True)
pymaid.plot3d(Single,width = 1200,color = 'k',by_strahler = True)
In [9]:
# plot a neuron with multiple dendrite tags!

n = pymaid.get_neurons('3813403')
Dend_nodes = n.tags['dendrite']
dend = pymaid.CatmaidNeuronList([n.prune_proximal_to(i,inplace = False) for i in Dend_nodes])
axon = n.prune_proximal_to('axon',inplace = False)
pymaid.plot3d([n,dend,axon],color = [(1,0,1),(1,1,0),(0,1,1),(0,1,1)])